package com.ss.android.article.base.app.account;

import android.content.Context;
import android.text.TextUtils;

import com.ss.android.account.v2.a.b;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.browser.R;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public final class a implements b {
    private Context a;
    private boolean b;
    private boolean c;
    private String d;
    private HashMap e;
    private HashMap f;

    public a(Context arg2) {
        this.c = true;
        this.e = new HashMap();
        this.f = new HashMap();
        this.a = arg2.getApplicationContext();
    }

    private static void a(JSONObject arg3, Map arg4) {
        Iterator v1 = arg3.keys();
        while (v1.hasNext()) {
            Object v0 = v1.next();
            arg4.put(v0, arg3.optString(((String) v0)));
        }
    }

    public final String a(String arg4) {
        Object v0_1;
        String v0 = null;
        int v2 = R.string.account_mobile_login;
        if (TextUtils.isEmpty(((CharSequence) arg4))) {
            v0 = this.a.getString(v2);
        } else {
            v0_1 = this.e.get(arg4);
            if (TextUtils.isEmpty(((CharSequence) v0_1))) {
                int v0_2 = -1;
                switch (arg4) {
                    case "title_register":
                        v0_2 = 0;
                        break;
                    case "title_favor":
                        v0_2 = 1;
                        break;
                    case "title_pgc_like":
                        v0_2 = 2;
                        break;
                }

                switch (v0_2) {
                    case 0: {
                        v0 = this.a.getString(com.ss.android.article.browser.R.string.account_dialog_title_register);
                        break;
                    }
                    case 1: {
                        v0 = this.a.getString(com.ss.android.article.browser.R.string.account_dialog_title_favor);
                        break;
                    }
                    case 2: {
                        v0 = this.a.getString(com.ss.android.article.browser.R.string.account_dialog_title_pgc_like);
                        break;
                    }
                    default:
                        v0 = this.a.getString(v2);
                        break;
                }

            }
        }
        return v0;
    }

    public final boolean a() {
        this.e();
        return this.c;
    }

    public final String b() {
        this.e();
        return TextUtils.isEmpty(this.d) ? this.a.getString(R.string.account_confirm_btn_txt) : this.d;
    }

    public final String c() {
        return AppData.getInstance().mMobileByTelecom;
    }

    public final JSONArray d() {
        return AppData.getInstance().getAppSettings().getThirdPartyLoginConfig();
    }

    private void e() {
        if (!this.b) {
            AppData v2 = AppData.getInstance();
            boolean v0 = v2.ssSyncAfterLogin != 0 ? true : false;
            this.c = v0;
            this.d = v2.mContext.getString(com.ss.android.article.browser.R.string.account_confirm_btn_txt);
            String v0_1 = v2.loginPageTitle;
            if (!TextUtils.isEmpty(v0_1)) {
                try {
                    JSONObject v2_1 = new JSONObject(v0_1);
                    JSONObject v0_3 = v2_1.optJSONObject("dialog_title");
                    if (v0_3 != null) {
                        a(v0_3, this.e);
                    }

                    v0_3 = v2_1.optJSONObject("quick_dialog_title");
                    if (v0_3 == null) {
                        this.b = true;
                        return;
                    }

                    a(v0_3, this.f);
                } catch (JSONException v0_2) {
                    v0_2.printStackTrace();
                }
            }
            this.b = true;
        }
    }
}

